using System;
using Akcedo.Framework.Infrastructure.ASPNet;
using StructureMap;

namespace FwkLight.Application
{
  public class ApplicationTask
  {
    public static void ClearApplicationTaskDataFromRequest()
    {
      ClearTaskEntitiesFromRequest();
      ClearFetchingConfigurationFromRequest();
    }

    public static void ClearTaskEntitiesFromRequest()
    {
      RequestItemDictionary req =
        ObjectFactory.GetInstance<RequestItemDictionary>();

      if (req.Contains(ApplicationConstants.Request.EntityInRequestList))
        req.Remove(ApplicationConstants.Request.EntityInRequestList);
    }

    public static void ClearFetchingConfigurationFromRequest()
    {
      RequestItemDictionary req =
        ObjectFactory.GetInstance<RequestItemDictionary>();

      if (req.Contains(ApplicationConstants.Request.FetchingConfigurationList))
        req.Remove(ApplicationConstants.Request.FetchingConfigurationList);
    }

    public static string CacheKey(string className, string cacheResetVariation)
    {
      return className + cacheResetVariation;
    }
  }
}